import { selfI18n } from '@/i18n/index';
export default function (BarXData, RunningBarData, IdelBarData, EstopBarData, OfflineBarData) {
    const $t = selfI18n;
    const title_map = {
        Running: $t('running'),
        Idle: $t('idle'),
        Estop: $t('estop'),
        Offline: $t('offline'),
        work_hour_count: $t('work_hour_count')
    };
    return {
        title: {
            text: title_map.work_hour_count + '（h）',
            top: '5%',
            textStyle: {
                fontSize: 14
            }
        },
        tooltip: {
            trigger: 'axis',
            formatter: (params) => {
                const unit = params[0].data !== '' ? 'h' : '';
                return `${params[0].axisValue}
                <br>${params[0].marker}${title_map.Running}：${params[0].data}${unit}
                <br>${params[1].marker}${title_map.Idle}：${params[1].data}${unit}
                <br>${params[2].marker}${title_map.Estop}：${params[2].data}${unit}
                <br>${params[3].marker}${title_map.Offline}：${params[3].data}${unit}`;
            }
        },
        xAxis: {
            data: BarXData,
            axisLabel: {
                formatter: (params) => {
                    return params.slice(5);
                }
            },
            axisTick: {
                show: false
            }
        },
        grid: {
            left: '2%',
            right: '0',
            bottom: '10%',
            containLabel: true
        },
        yAxis: {
            max: 24,
            axisLine: {
                show: false
            },
            axisTick: {
                show: false
            }
        },
        series: [
            {
                data: RunningBarData,
                type: 'bar',
                stack: 'workHourCount',
                itemStyle: {
                    color: '#4dca72'
                },
                barWidth: '35%',
                label: {
                    show: false,
                    formatter: (params) => {
                        return `${params.data}h`;
                    }
                }
            },
            {
                data: IdelBarData,
                type: 'bar',
                stack: 'workHourCount',
                itemStyle: {
                    color: '#fcda55'
                },
                barWidth: '35%',
                label: {
                    show: false,
                    formatter: (params) => {
                        return `${params.data}h`;
                    }
                }
            },
            {
                data: EstopBarData,
                type: 'bar',
                stack: 'workHourCount',
                itemStyle: {
                    color: '#f2637b'
                },
                barWidth: '35%',
                label: {
                    show: false,
                    formatter: (params) => {
                        return `${params.data}h`;
                    }
                }
            },
            {
                data: OfflineBarData,
                type: 'bar',
                stack: 'workHourCount',
                itemStyle: {
                    color: '#cccccc'
                },
                barWidth: '35%',
                label: {
                    show: false,
                    formatter: (params) => {
                        return `${params.data}h`;
                    }
                }
            }
        ]
    };
}
